﻿
namespace DAPNet
{
    public class RecursiveMedianFilter : IOfflineEffect
    {
        private MedianFilter medianFilter;


        public RecursiveMedianFilter(int parameter)
        {
            this.medianFilter = new MedianFilter(parameter);
        }

        public int Parameter
        {
            get 
            { 
                return medianFilter.Parameter; 
            }
            set 
            { 
                medianFilter.Parameter = value; 
            }
        }

        public void Process(SampleCollection samples)
        {
            for (int i = 0; i < samples.Count; i++)
            {
                double medianValue = medianFilter.GetMedianValueAt(samples, i);
                samples[i].SetTrimmedValue(medianValue);
            }
        }
    }
}
